var util = require('../../libs/util.js');
var app = getApp();
Page({
  data: {
    index: '',
    price:0,
    distance:0,
    incomeService: {
      income: 180,
      mile: 0,
      backmile: 0,
      shopReward: 0,
      stevedoreReward: 0,
      overtimeReward: 0
    }
  },
  onShareAppMessage: function () {
    return {
      title: app.appName,
      path: '/pages/index/index'
    }
  },
  onLoad: function (e) {
    wx.setNavigationBarTitle({ "title": app.appName +"--价格预估" });
    var startPrice = Number(e.startPrice), milePrice = Number(e.milePrice), pointPrice = Number(e.pointPrice);
    var distance = Number(e.distance);
    if (distance < 5) {
      distance = 5;
    }
    this.setData({
      index: e.index,
      startPrice: startPrice,
      milePrice: milePrice,
      pointPrice: pointPrice,
      distance: e.distance,
      returnPrice: e.returnPrice,
      point: e.point,
      price: Number(e.price).toFixed(0),
      incomeService: {
        startPrice: startPrice,
        mile: Number((distance - 5) * milePrice).toFixed(0),
        mile_text: distance,
        backmile: Number(e.returnPrice).toFixed(0),
        shopReward: Number(Number(e.point) * pointPrice).toFixed(0),
        shopReward_text: e.point,
        stevedoreReward: 0,
        overtimeReward: 0
      }
    });
    wx.removeStorage({
      key: 'warehouseConfig',
      success: function (res) {
      }
    });
  },
  onReady: function () {
    wx.hideToast()
  },
  bindInput: function (e) {
    var item = String(e.currentTarget.id), item_value = {};
    item_value[item] = e.detail.value;
    this.setData(item_value);
  },
  cancelConfirmData: function () {
    wx.navigateBack({
      delta: 1
    })
  },
  pathPriceDetailDesc:function(){
    wx.navigateTo({
      url: '/pages/index/pathPriceDetailDesc'
    })
  }
});